Skip to content

fix: filter NUL bytes from input method events - #732

Closed
pengfeixx wants to merge 1 commit into
linuxdeepin:masterfrom
pengfeixx:agent/bugfix/372753
Closed

pengfeixx wants to merge 1 commit into
linuxdeepin:masterfrom
pengfeixx:agent/bugfix/372753

Conversation

@pengfeixx

@pengfeixx pengfeixx commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

fix: filter NUL bytes from input method events

  1. Root cause: inputMethodEvent received commitString/preeditString
    from input methods without filtering NUL bytes (\x00), which were
    written into the document via insertSelectTextEx and persisted to
    file on save
  2. Fix: remove NUL bytes from the text string before passing it to
    insertSelectTextEx, and skip insertion entirely if text becomes
    empty after removal
  3. Impact: only affects text containing NUL bytes (e.g. from Sogou
    soft keyboard); normal text input is unaffected

Influence:

  1. Test input method commit with normal text to verify no regression
  2. Test input method commit with NUL-containing text to verify NUL
    bytes are filtered
  3. Test file save and reopen after NUL-containing input to verify
    no invalid character NULL warning

fix: 过滤输入法事件中的 NUL 字节

  1. 根因:inputMethodEvent 接收输入法的 commitString/preeditString
    时未过滤 NUL 字节(\x00),NUL 字节经 insertSelectTextEx 写入文档
    并在保存时持久化到文件
  2. 方案:在传入 insertSelectTextEx 之前移除 NUL 字节,移除后若文本
    为空则跳过插入
  3. 影响:仅影响含 NUL 字节的文本(如搜狗软键盘输入),正常文本输入
    不受影响

Influence:

  1. 测试输入法正常输入文字(中文、英文、数字),验证无回归
  2. 测试输入法提交含 NUL 字节的文本,验证 NUL 字节被过滤
  3. 测试含 NUL 输入后保存并重新打开文件,验证不再提示无效字符NULL

PMS: BUG-372753

Summary by Sourcery

Bug Fixes:

  • Prevent NUL bytes from input method commit and preedit text from being inserted into documents or persisted to files.

1. Root cause: inputMethodEvent received commitString/preeditString
   from input methods without filtering NUL bytes (\x00), which were
   written into the document via insertSelectTextEx and persisted to
   file on save
2. Fix: remove NUL bytes from the text string before passing it to
   insertSelectTextEx, and skip insertion entirely if text becomes
   empty after removal
3. Impact: only affects text containing NUL bytes (e.g. from Sogou
   soft keyboard); normal text input is unaffected

Influence:
1. Test input method commit with normal text to verify no regression
2. Test input method commit with NUL-containing text to verify NUL
   bytes are filtered
3. Test file save and reopen after NUL-containing input to verify
   no invalid character NULL warning

fix: 过滤输入法事件中的 NUL 字节

1. 根因:inputMethodEvent 接收输入法的 commitString/preeditString
   时未过滤 NUL 字节(\x00),NUL 字节经 insertSelectTextEx 写入文档
   并在保存时持久化到文件
2. 方案:在传入 insertSelectTextEx 之前移除 NUL 字节,移除后若文本
   为空则跳过插入
3. 影响:仅影响含 NUL 字节的文本(如搜狗软键盘输入),正常文本输入
   不受影响

Influence:
1. 测试输入法正常输入文字(中文、英文、数字),验证无回归
2. 测试输入法提交含 NUL 字节的文本,验证 NUL 字节被过滤
3. 测试含 NUL 输入后保存并重新打开文件,验证不再提示无效字符NULL

PMS: BUG-372753
@deepin-ci-robot

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@sourcery-ai

sourcery-ai Bot commented Nov 16, 2026

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Filter NUL characters from preedit or committed input-method text and skip insertion when nothing remains.

  • src/editor/dtextedit.cpp L7596-7598, L7615

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: pengfeixx

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@deepin-bot

deepin-bot Bot commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 6.6.10
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #746

@deepin-bot

deepin-bot Bot commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 6.6.11
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #757

@deepin-bot

deepin-bot Bot commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 6.6.12
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #758

@pengfeixx pengfeixx closed this Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants